Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
Next.js routing from "pages/[...slug].js" not working

This is how my pages folder looks like:

pages
   index.js  
   [...slug].js

I know that the problem lies for sure in the fact that I am using catch all routes directly in the pages folder, because I tried with a "pages/page/[...slug].js structure and everything works fine.

When navigating using the Link component from the index.js page to a [...slug].js page (e.g. /careers or /blog), everything works fine.

BUT when navigating from a [...slug].js page (e.g. /contact) to another similar page (e.g. /blog) only the URL changes correctly, but the content of the page stays the same, so there is no rerendering.

Note: Navigating from a [...slug].js page back to the root file (href="/") works.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

TLDR:
When returning the set of props from your getStaticProps or getServerSideProps function, return a "key" prop and assign it a unique value, so that react is able to differentiate between the two pages that are served from the same dynamic path.

I found the solution to the "problem" in github issue from last year: https://github.com/vercel/next.js/issues/9992

You can find a clear solution reading through the issue I linked.

about 4 years ago · Juan Pablo Isaza Report

0

Make each page its own file within your pages folder. For example, you could have:

pages/
  index.js
  contact.js
  careers.js
  blog.js

Each file should export a default function that returns JSX.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!